package com.loyal.mwm.libs.api

import okhttp3.ResponseBody
import okhttp3.RequestBody
import com.loyal.mwm.beans.WeatherBean
import com.loyal.mwm.impl.ServerImpl
import retrofit2.http.*

interface ApiActionServer {
    @FormUrlEncoded
    @POST(ServerImpl.ACTION + "register")
    suspend fun register(@Field("beanJson") json: String?): String?

    @FormUrlEncoded
    @POST(ServerImpl.ACTION + "loginByParams")
    suspend fun loginByParams(
        @Field("username") account: String?,
        @Field("password") password: String?
    ): String?

    @FormUrlEncoded
    @POST(ServerImpl.ACTION + "login")
    suspend fun loginByJson(@Field("beanJson") json: String?): String?

    @FormUrlEncoded
    @POST(ServerImpl.ACTION + "queryUser")
    suspend fun queryAccount(@Field("username") account: String?): String?

    @FormUrlEncoded
    @POST(ServerImpl.ACTION + "accountDestroy")
    suspend fun accountDestroy(@Field("beanJson") json: String?): String?

    @FormUrlEncoded
    @Streaming
    @POST(ServerImpl.ACTION + "showAvatar")
    suspend fun showAvatar(@Field("username") account: String?): ResponseBody?

    @FormUrlEncoded
    @POST(ServerImpl.ACTION + "updateUser")
    suspend fun accountUpdate(@Field("beanJson") json: String?): String?

    @FormUrlEncoded
    @POST(ServerImpl.ACTION + "passwordUpdate")
    suspend fun passwordUpdate(@Field("beanJson") json: String?): String?

    @FormUrlEncoded
    @POST(ServerImpl.ACTION + "accountLock")
    suspend fun accountLock(@Field("username") account: String?): String?

    @Multipart
    @POST(ServerImpl.ACTION + "updateAvatar")
    suspend fun updateAvatar(
        @Part("description") description: RequestBody?,
        @Part iconFile: Part?
    ): String?

    @FormUrlEncoded
    @POST(ServerImpl.ACTION + "feedback")
    suspend fun feedback(@Field("beanJson") json: String?): String?

    @FormUrlEncoded
    @POST(ServerImpl.ACTION + "getFeedback")
    suspend fun getFeedback(@Field("username") account: String?): String?

    @FormUrlEncoded
    @POST(ServerImpl.ACTION + "deleteFeedback")
    suspend fun deleteFeedback(@Field("beanJson") json: String?): String?

    @FormUrlEncoded
    @POST(ServerImpl.ACTION + "scan")
    suspend fun scan(
        @Field("beanJson") json: String?,
        @Field("param") param: String?
    ): String?

    @FormUrlEncoded
    @POST(ServerImpl.ACTION + "checkUpdate")
    suspend fun checkUpdate(@Field("version") version: String?): String?

    @Streaming
    @GET
    suspend fun downloadImage(@Url url: String?): ResponseBody?

    @GET
    suspend fun getWeather(@Url url: String?): WeatherBean?
}